//
//  ImagePushButton.m
//  wulihan
//
//  Created by tang on 16/3/24.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "ImagePushButton.h"
#import "Header.h"

@interface ImagePushButton ()
{
    UILabel *lable;
    UIButton *button;
}

@end



@implementation ImagePushButton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUserInteractionEnabled:YES];
        
        lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 6.0, self.bounds.size.width, 15.0)];
        [lable setTextAlignment:NSTextAlignmentCenter];
        [lable setTextColor:uicolor(182, 120, 5)];
        [lable setFont:[UIFont systemFontOfSize:11.0]];
        [self addSubview:lable];
        
        [self.layer setBorderWidth:1.0f];
        [self.layer setBorderColor:uicolor(182, 120, 5).CGColor];
        [self.layer setCornerRadius:13.0];
        
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(push)];
        [self addGestureRecognizer:tap];
        
        
        
    }
    return self;
}




- (void)setNumberInt:(int)numberInt
{
    
    if (numberInt == 0)
    {
        [lable setText:@"继续"];
        [self setBackgroundColor:[UIColor colorWithWhite:1.0 alpha:0.5]];
        [self setUserInteractionEnabled:NO];
    }
    else
    {
        [self setUserInteractionEnabled:YES];
        [lable setText:[NSString stringWithFormat:@"继续(%d)", numberInt]];
        [self setBackgroundColor:[UIColor whiteColor]];
    }
}





- (void)push
{
    if (_MImagePushButtonDelegate && [_MImagePushButtonDelegate respondsToSelector:@selector(pushToCreatView)])
    {
        [_MImagePushButtonDelegate pushToCreatView];
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
